package com.itheima.tcp.socketFile;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServiceFile {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10000);
        Socket socket = serverSocket.accept();

        BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("day16_网络编程\\ServiceDir\\img.jpg"));
        int b;
        while ((b = bis.read()) != -1){
            bos.write(b);
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        bw.write("上传成功");
        bw.newLine();
        bw.flush();
        bos.close();
        socket.close();
    }
}
